package com.hsc.yalebao.weight;

import android.content.Context;
import android.content.res.Resources;
import android.text.Html;
import android.text.Spanned;
import android.text.method.LinkMovementMethod;
import android.util.DisplayMetrics;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup.LayoutParams;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.PopupWindow.OnDismissListener;
import android.widget.TextView;
import com.google.gson.Gson;
import com.hsc.yalebao.adapter.OddsListViewAdapter;
import com.hsc.yalebao.base.ActivityStack;
import com.hsc.yalebao.base.CustomApplication;
import com.hsc.yalebao.base.MainActivity;
import com.hsc.yalebao.http.AppConstants;
import com.hsc.yalebao.http.RequestNet;
import com.hsc.yalebao.model.PlayRuleBaseBean;
import com.hsc.yalebao.model.PlayRuleListBaseBean;
import com.hsc.yalebao.model.PlayRuleResultBean;
import com.hsc.yalebao.model.PlayStyleBaseBean;
import com.hsc.yalebao.tools.UiUtil;
import com.zhy.http.okhttp.callback.StringCallback;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.HashMap;
import okhttp3.Call;

public class MyOddsPopuWindow extends PopupWindow
{
  private String TAG = "MyOddsPopuWindow";
  public OddsListViewAdapter adapterCai;
  public OddsListViewAdapter adapterDa;
  public OddsListViewAdapter adapterTe;
  private MyDialogListener cancleListener = null;
  private Context context;
  public ArrayList<PlayRuleBaseBean> dataCai = new ArrayList();
  public ArrayList<PlayRuleBaseBean> dataDa = new ArrayList();
  public ArrayList<PlayRuleBaseBean> dataTe = new ArrayList();
  private MyDialogListener defaultListener = null;
  private float heightProportion = 0.9F;
  private LinearLayout layout_body;
  private SelfListView lv_cai;
  private SelfListView lv_daxiao;
  private SelfListView lv_teshu;
  private MyDialogListener okListener = null;
  public ArrayList<PlayStyleBaseBean> playStyleBaseBeans = new ArrayList();
  private PopupWindow popwindow;
  public ArrayList<PlayRuleListBaseBean> result = new ArrayList();
  String roomId;
  private TextView tv_close;
  private TextView tv_shuoming;
  View view;
  private float widthProportion = 0.9F;

  public MyOddsPopuWindow(Context paramContext, String paramString)
  {
    super(paramContext);
    this.context = paramContext;
    this.roomId = paramString;
    this.view = LayoutInflater.from(paramContext).inflate(2130903159, null);
    if (this.popwindow == null)
      this.popwindow = new PopupWindow(this.view, -2, -2, true);
    this.layout_body = ((LinearLayout)this.view.findViewById(2131100063));
    this.tv_close = ((TextView)this.view.findViewById(2131100179));
    this.tv_shuoming = ((TextView)this.view.findViewById(2131100183));
    this.lv_daxiao = ((SelfListView)this.view.findViewById(2131100185));
    this.lv_cai = ((SelfListView)this.view.findViewById(2131100186));
    this.lv_teshu = ((SelfListView)this.view.findViewById(2131100181));
    if (this.adapterDa == null)
      this.adapterDa = new OddsListViewAdapter(paramContext, this.dataDa);
    this.lv_daxiao.setAdapter(this.adapterDa);
    if (this.adapterCai == null)
      this.adapterCai = new OddsListViewAdapter(paramContext, this.dataCai);
    this.lv_cai.setAdapter(this.adapterCai);
    if (this.adapterTe == null)
      this.adapterTe = new OddsListViewAdapter(paramContext, this.dataTe);
    this.lv_teshu.setAdapter(this.adapterTe);
    this.tv_close.setOnClickListener(new View.OnClickListener()
    {
      public void onClick(View paramAnonymousView)
      {
        MyOddsPopuWindow.this.popwindow.dismiss();
      }
    });
    setDialogSize(this.widthProportion, this.heightProportion, 17);
  }

  private void getPlayRuleInfo()
  {
    String str = getPlayStyleId(0) + "," + getPlayStyleId(1) + "," + getPlayStyleId(2);
    HashMap localHashMap = new HashMap();
    localHashMap.put("playid", str);
    localHashMap.put("roomid", this.roomId);
    LogUtils.i(this.TAG, "playid:" + str);
    LogUtils.i(this.TAG, "roomid:" + this.roomId);
    LogUtils.i(this.TAG, "URL:" + AppConstants.URL_GET_RULE_INFO_LIST);
    RequestNet.get(this.context, AppConstants.URL_GET_RULE_INFO_LIST, localHashMap, new StringCallback()
    {
      public void onError(Call paramAnonymousCall, Exception paramAnonymousException)
      {
        LogUtils.e(MyOddsPopuWindow.this.TAG, "获取失败,getPlaytList-result:" + paramAnonymousException);
      }

      public void onResponse(String paramAnonymousString)
      {
        LogUtils.d(MyOddsPopuWindow.this.TAG, "result:" + paramAnonymousString);
        if ((paramAnonymousString == null) || ("".equals(paramAnonymousString)))
        {
          LogUtils.e(MyOddsPopuWindow.this.TAG, "result:" + paramAnonymousString);
          return;
        }
        Gson localGson = new Gson();
        try
        {
          localPlayRuleResultBean = (PlayRuleResultBean)localGson.fromJson(paramAnonymousString, PlayRuleResultBean.class);
          if (localPlayRuleResultBean == null)
          {
            LogUtils.e(MyOddsPopuWindow.this.TAG, "getCurrSecond-issueTimeBean == null，获取失败");
            return;
          }
        }
        catch (Exception localException)
        {
          PlayRuleResultBean localPlayRuleResultBean;
          while (true)
          {
            localException.printStackTrace();
            localPlayRuleResultBean = null;
          }
          String[] arrayOfString = localPlayRuleResultBean.getDescription().replaceAll("\r\n", "<br>").split("④");
          if ((arrayOfString != null) && (arrayOfString.length == 2))
          {
            String str2 = new StringBuilder("<font color='#333333'>").append(arrayOfString[0]).append("</font>").toString() + "<font color='#FF0001'>④" + arrayOfString[1] + "</font>";
            Spanned localSpanned = Html.fromHtml(str2);
            LogUtils.e(MyOddsPopuWindow.this.TAG, "html:" + str2);
            MyOddsPopuWindow.this.tv_shuoming.setText(localSpanned);
            MyOddsPopuWindow.this.tv_shuoming.setMovementMethod(LinkMovementMethod.getInstance());
          }
          LogUtils.e(MyOddsPopuWindow.this.TAG, "ruleBean.getDescription()：" + localPlayRuleResultBean.getDescription());
          int i;
          if (localPlayRuleResultBean.getFlag() == 1)
          {
            MyOddsPopuWindow.this.result = localPlayRuleResultBean.getResult();
            if (MyOddsPopuWindow.this.result != null)
            {
              i = 0;
              if (i < MyOddsPopuWindow.this.result.size())
                break label357;
            }
          }
          if (localPlayRuleResultBean.getFlag() == -2)
          {
            MainActivity.mainActivity.showOffLineDialog();
            return;
            label357: PlayRuleListBaseBean localPlayRuleListBaseBean = (PlayRuleListBaseBean)MyOddsPopuWindow.this.result.get(i);
            if (localPlayRuleListBaseBean == null);
            while (true)
            {
              i++;
              break;
              String str1 = localPlayRuleListBaseBean.getPlayname();
              if ("大小单双".equals(str1))
              {
                MyOddsPopuWindow.this.dataDa = localPlayRuleListBaseBean.getData();
                MyOddsPopuWindow.this.setDataDa(MyOddsPopuWindow.this.dataDa);
              }
              else if ("猜数字".equals(str1))
              {
                MyOddsPopuWindow.this.dataCai = localPlayRuleListBaseBean.getData();
                MyOddsPopuWindow.this.setDataCai(MyOddsPopuWindow.this.dataCai);
              }
              else if ("特殊玩法".equals(str1))
              {
                MyOddsPopuWindow.this.dataTe = localPlayRuleListBaseBean.getData();
                MyOddsPopuWindow.this.setDataTe(MyOddsPopuWindow.this.dataTe);
              }
            }
          }
          if (localPlayRuleResultBean.getFlag() == -4)
          {
            ActivityStack.getInstance().backToMain(MainActivity.class, MyOddsPopuWindow.this.context);
            return;
          }
          UiUtil.showToast(MyOddsPopuWindow.this.context, localPlayRuleResultBean.getMsg());
          LogUtils.e(MyOddsPopuWindow.this.TAG, "获取投注类型根据玩法 getPlaytListRule:" + localPlayRuleResultBean.getMsg());
        }
      }
    });
  }

  private int getPlayStyleId(int paramInt)
  {
    int i = -1;
    if ((this.playStyleBaseBeans != null) && (this.playStyleBaseBeans.size() != 0))
    {
      if (paramInt > -1 + this.playStyleBaseBeans.size())
      {
        LogUtils.e(this.TAG, "getPlayStyleId()-下标越界！");
        return i;
      }
      PlayStyleBaseBean localPlayStyleBaseBean = (PlayStyleBaseBean)this.playStyleBaseBeans.get(paramInt);
      if (localPlayStyleBaseBean == null)
      {
        LogUtils.e(this.TAG, "getPlayStyleId()-model == null！");
        return i;
      }
      i = localPlayStyleBaseBean.getId();
    }
    return i;
  }

  public void setDataCai(ArrayList<PlayRuleBaseBean> paramArrayList)
  {
    this.dataCai = paramArrayList;
    if (this.adapterCai != null)
    {
      this.adapterCai.setData(paramArrayList);
      this.adapterCai.notifyDataSetChanged();
      LogUtils.i(this.TAG, "dataCai.size():" + paramArrayList.size());
      return;
    }
    LogUtils.e(this.TAG, "adapterCai == null");
  }

  public void setDataDa(ArrayList<PlayRuleBaseBean> paramArrayList)
  {
    this.dataDa = paramArrayList;
    if (this.adapterDa != null)
    {
      this.adapterDa.setData(paramArrayList);
      this.adapterDa.notifyDataSetChanged();
      LogUtils.i(this.TAG, "dataDa.size():" + paramArrayList.size());
      return;
    }
    LogUtils.e(this.TAG, "adapterDa == null");
  }

  public void setDataTe(ArrayList<PlayRuleBaseBean> paramArrayList)
  {
    this.dataTe = paramArrayList;
    if (this.adapterTe != null)
    {
      this.adapterTe.setData(paramArrayList);
      this.adapterTe.notifyDataSetChanged();
      LogUtils.i(this.TAG, "dataTe.size():" + paramArrayList.size());
      return;
    }
    LogUtils.e(this.TAG, "adapterTe == null");
  }

  public void setDialogSize(float paramFloat1, float paramFloat2, int paramInt)
  {
    int i = CustomApplication.app.displayMetrics.widthPixels;
    int j = CustomApplication.app.displayMetrics.heightPixels;
    ViewGroup.LayoutParams localLayoutParams = this.layout_body.getLayoutParams();
    localLayoutParams.height = ((int)(paramFloat2 * j));
    localLayoutParams.width = i;
    this.layout_body.setLayoutParams(localLayoutParams);
  }

  public void setOnButtonGroupClick(MyDialogListener paramMyDialogListener1, MyDialogListener paramMyDialogListener2)
  {
    this.cancleListener = paramMyDialogListener1;
    this.okListener = paramMyDialogListener2;
  }

  public void setOnButtonGroupClick(String paramString1, MyDialogListener paramMyDialogListener1, String paramString2, MyDialogListener paramMyDialogListener2)
  {
    this.cancleListener = paramMyDialogListener1;
    this.okListener = paramMyDialogListener2;
  }

  public void setOnDefaultButtonClick(MyDialogListener paramMyDialogListener)
  {
    this.defaultListener = paramMyDialogListener;
  }

  public void setOnDefaultButtonClick(String paramString, MyDialogListener paramMyDialogListener)
  {
    this.defaultListener = paramMyDialogListener;
  }

  public void setOnDismissListener(PopupWindow.OnDismissListener paramOnDismissListener)
  {
    RequestNet.cancelTag(this.context);
    super.setOnDismissListener(paramOnDismissListener);
  }

  public void setPlayStyleData(ArrayList<PlayStyleBaseBean> paramArrayList)
  {
    this.playStyleBaseBeans = paramArrayList;
  }

  public void show(View paramView)
  {
    if ((this.result == null) || (this.result.size() == 0))
      getPlayRuleInfo();
    this.tv_close = ((TextView)this.view.findViewById(2131100179));
    this.tv_close.requestFocus();
    this.popwindow.setFocusable(true);
    this.popwindow.setOutsideTouchable(true);
    this.popwindow.setBackgroundDrawable(this.context.getResources().getDrawable(2130837536));
    this.popwindow.showAtLocation(paramView, 80, 0, 0);
    this.popwindow.setOnDismissListener(new PopupWindow.OnDismissListener()
    {
      public void onDismiss()
      {
        System.out.println("popWindow消失");
      }
    });
  }

  public static abstract interface MyDialogListener
  {
    public abstract void onClick();
  }
}

/* Location:           C:\Users\user\Desktop\dd28_pcdd720\classes_dex2jar.jar
 * Qualified Name:     com.hsc.yalebao.weight.MyOddsPopuWindow
 * JD-Core Version:    0.6.2
 */